#include <iostream>
#include <vector>
using namespace std;

class Idisplay
{
public:
    virtual void Show(double temperature) = 0;
};

class display1 : public Idisplay
{
public:
    virtual void Show(double temperature) {}
};

class display2 : public Idisplay
{
public:
    virtual void Show(double temperature) {}
};

class display3 : public Idisplay
{
public:
    virtual void Show(double temperature) {}
};

class WeatherData
{
};

class DataCenter
{
public:
    void Attach(Idisplay *ob) {}

    void Detach(Idisplay *ob) {}

    void TempNotify()
    {
        double temper = CalcTemperature();
        for (auto &ob : _obs)
            ob->Show(temper);
    }

private:
    float CalcTemperature()
    {
        WeatherData *data = GetWeatherData();
        float temperature;
        // 处理数据
        return temperature;
    }

private:
    WeatherData *GetWeatherData();
    std::vector<Idisplay *> _obs;
};

// 发布数据
int main()
{
    DataCenter *dc;
    display1 *d1 = new display1;
    display2 *d2 = new display2;
    display3 *d3 = new display3;
    dc->Attach(d1);
    dc->Attach(d2);
    dc->Attach(d3);
    dc->TempNotify();

    dc->Detach(d1);
    return 0;
}